//
//  HotTripCell.m
//  RoadLine
//
//  Created by dllo on 15/4/21.
//  Copyright (c) 2015年 RedFireNoodles. All rights reserved.
//

#import "HotTripCell.h"
#import "Singleton.h"
#import "NightManager.h"

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height


@implementation HotTripCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.view = [[UIView alloc] init];
        self.view.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor colorWithRed:250/255.0 green:245/255.0 blue:232/255.0 alpha:1];
        [self.contentView addSubview:self.view];
        [_view release];
        
        self.labelView = [[UIView alloc] init];
        self.labelView.backgroundColor = [UIColor whiteColor];
        self.labelView.alpha = 0.6;
        [self.view addSubview:self.labelView];
        [_labelView release];
        
        
        self.tripImageView = [[UIImageView alloc] init];
        [self.view addSubview:self.tripImageView];
        self.tripImageView.layer.cornerRadius = 8;
        self.tripImageView.clipsToBounds = YES;
        [_tripImageView release];
        
        self.tripDayLabel = [[UILabel alloc] init];
        [self.labelView addSubview:self.tripDayLabel];
        [_tripDayLabel release];
        self.tripDayLabel.font = [UIFont systemFontOfSize:8];

               
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.backgroundColor = [UIColor clearColor];
        [self.labelView addSubview:self.titleLabel];
        [_titleLabel release];
        self.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];

        
        self.placeLabel = [[UILabel alloc] init];
        self.placeLabel.backgroundColor = [UIColor clearColor];
        [self.labelView addSubview:self.placeLabel];
        [_placeLabel release];
        self.placeLabel.font = [UIFont systemFontOfSize:8];
        
                  }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.tripImageView.frame = CGRectMake(25, 10, WIDTH-50, 150);
    self.tripImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.tripImageView.autoresizesSubviews = YES;
    self.tripImageView.clipsToBounds = YES;
    self.tripDayLabel.frame = CGRectMake(10, 30, WIDTH-50 , 10);
    self.placeLabel.frame = CGRectMake(10, 40, WIDTH-50, 10);
    self.titleLabel.frame = CGRectMake(10, 5, WIDTH - 50, 30);
    self.view.frame = CGRectMake(0, 0, WIDTH, 140);
    self.labelView.frame = CGRectMake(25, 25, WIDTH - 50, 55);
    [self.view bringSubviewToFront:self.labelView];
    // 夜间模式
    if ([Singleton shareSingleton].isNight) {
        [[Singleton shareSingleton] loadNightModeInfoFormDisk];
    }
    
}

- (void)setLightDayModel {
    self.contentView.backgroundColor = [UIColor colorWithRed:250/255.0 green:245/255.0 blue:232/255.0 alpha:1];
    [NightManager setLabelColorWithLabel:self.tripDayLabel];
    [NightManager setLabelColorWithLabel:self.titleLabel];
    [NightManager setBackgroundColorWithView:self.labelView];
    
}

- (void)setNightDayModel {
    [NightManager setBackgroundColorWithView:self.contentView];
    [NightManager setLabelColorWithLabel:self.tripDayLabel];
    [NightManager setLabelColorWithLabel:self.titleLabel];
    [NightManager setBackgroundColorWithView:self.labelView];
}

-(void)dealloc{
    [_tripDayLabel release];
    [_tripImageView release];
    [_titleLabel release];
    [_placeLabel release];
    [_view release];
    [super dealloc];
}



@end
